import Vue from "vue";
import App from "./App";
import {
	router,
	RouterMount
} from "@/shopro/router";
import store from "@/shopro/store";
import uView from "uview-ui";
import shopro from "@/shopro";
import PrivacyService from '@/shopro/utils/privacy'

// 挂载服务到Vue原型
Vue.prototype.$privacy = PrivacyService

// // 封装安全跳转方法
// Vue.prototype.$safeNavigateTo = async function(url) {
// 	const agreed = uni.getStorageSync('privacyAgreed')
// 	if (!agreed) {
// 		try {
// 			await this.$privacy.check()
// 			uni.navigateTo({ url })
// 		} catch {
// 			console.log('用户拒绝协议')
// 		}
// 	} else {
// 		uni.navigateTo({ url })
// 	}
// }
async function bootstrap() {
	App.mpType = "app";
	//引入路由
	Vue.use(router);
	// 引入全局uView
	Vue.use(uView);
	// 加载shopro
	Vue.use(shopro);

	const app = new Vue({
		store,
		...App
	});
	// #ifdef H5
	RouterMount(app, router, "#app");
	// #endif
	// #ifndef H5
	app.$mount();
	// #endif
}

bootstrap();
